/*--------------------------------------------------------------------------------------*\
**
** blacksmith_window.h
**
** Heroes IV
** Copyright 2000, The 3DO Company
**
\*--------------------------------------------------------------------------------------*/

#ifndef BLACKSMITH_WINDOW_H_INCLUDED
#define BLACKSMITH_WINDOW_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#pragma warning( disable: 4786 )

#include <vector>
#include "artifact_type.h"
#include "bitmap_group_ptr.h"
#include "bitmap_group_cache.h"
#include "bitmap_group_window.h"
#include "bitmap_layer_cache_window.h"
#include "button.h"
#include "creature_array_window_ptr.h"
#include "creature_stack.h"
#include "game_window.h"

class t_army;
class t_adventure_frame;
class t_button;
class t_player;
class t_text_window;
class t_toggle_button;
class t_town;

/*
** Blacksmith arrow buttons.
*/
class t_blacksmith_button : public t_button
{
public:
    t_blacksmith_button( t_button *icon_button_ptr, t_cached_ptr<t_button_bitmaps>& bitmaps, t_screen_point point,
		      t_window* parent, std::string const& text = "" );
    virtual void     left_button_down( t_mouse_event const& event ); 
    virtual void     left_button_up( t_mouse_event const& event );
    virtual void     mouse_leaving( t_window* old_window, t_window* new_window,
		                            t_mouse_event const& event );
protected:
	t_button                *m_icon_button_ptr;
};


// Item structure.
typedef struct t_blacksmith_item_struct
{
	t_text_window *         cost_window_ptr;
	t_window_ptr		    disabled_inset_ptr;
	t_blacksmith_button *   down_button_ptr;
    t_artifact_type         item_type;
	t_button *				icon_button_ptr;
	t_text_window *         number_window_ptr;
	t_window_ptr		    pressed_inset_ptr;
    int                     quantity;
	t_window_ptr		    released_inset_ptr;
	t_text_window *         released_inset_text_ptr;
	bool                    spot_taken;
	t_blacksmith_button *   up_button_ptr;
} t_blacksmith_item;

enum { 
    k_max_items    = 4,
    k_max_potions  = 5,
    k_blacksmith_quantity_limit = 9999,
    k_creature_top_window_height = 72,
};

class t_blacksmith_window : public t_window
{
public:
	t_blacksmith_window( t_town const* town, t_army const* adjacent_army, t_adventure_frame* frame, t_window* parent );
    //void hero_select( t_creature_array_window* window, int slot );

protected:
	t_bitmap_group_ptr		m_background_bitmaps_ptr;
	t_bitmap_group_ptr	    m_picture_bitmaps_ptr;
	t_town *			    m_town;
    t_adventure_frame*      m_frame;
    t_blacksmith_item       m_items[k_max_items];
    t_blacksmith_item       m_potions[k_max_potions];
	t_army *			    m_adj_army_ptr;
	t_creature_array_window *m_garrison_window_ptr;
	t_creature_array_window *m_visitor_window_ptr;
	t_creature_array_window *m_selected_window_ptr;
	t_bitmap_layer_window   *m_selected_creature_window_ptr;
	t_player *			    m_player_ptr;
	int						m_player_funds;
	int						m_current_cost;
	t_text_window*          m_cost_window_ptr;
	t_text_window*          m_total_gold_text_ptr;
    t_button*               m_buy_button_ptr;

    void add_to_total_cost(int amount);
    void buy_click( t_button* );
    bool check_buy_button_disable();
    void create_creature_windows();
    void creature_double_click( t_creature_array_window* window, int slot );
    void close_click( t_button* );
    void create_item_display( t_artifact_type item_type, t_window* bg_window_ptr, t_blacksmith_item *item );
    t_creature_stack *  get_selected_creature();
    void item_clicked_up( t_button*, t_blacksmith_item *item );
    void item_clicked_down( t_button*, t_blacksmith_item *item );
    void hero_select( t_creature_array_window* window_ptr, int slot );
    void show_current_hero( t_creature_array_window* window_ptr, int slot );
    void subtract_from_total_cost(int amount);
    void show_current_creature( );
};

#endif // BLACKSMITH_WINDOW_H_INCLUDED

